package node;

import parser.Parser;

import java.io.IOException;

public class ConstExpNode extends ASTNode {
    public final String name = "<ConstExp>";
    // ConstExp → AddExp
    private final AddExpNode addExpNode;

    public ConstExpNode(AddExpNode addExpNode) {
        this.addExpNode = addExpNode;
    }

    @Override
    public void show() throws IOException {
        addExpNode.show();
        Parser.parserWriter.write(name + "\n");
    }

    public int calculate() {
        // 确定当前ConstExp是常数或者常量的加减乘除计算，即一定可以被计算出具体的数值
        // 输入：AddExpNode addExpNode
        // 输出：一个int类型的数字
        return addExpNode.calculate();
    }

}
